package io.renren.modules.user.service.impl;

import io.renren.modules.combat.entity.TFightDictionaryEntity;
import io.renren.modules.generator.entity.TTrainingDictionaryEntity;
import io.renren.modules.user.dao.TPeopleDictionaryDao;
import io.renren.modules.user.entity.TPeopleDictionaryEntity;
import io.renren.modules.user.service.TPeopleDictionaryService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import javax.validation.constraints.NotNull;


@Service("tPeopleDictionaryService")
public class TPeopleDictionaryServiceImpl extends ServiceImpl<TPeopleDictionaryDao, TPeopleDictionaryEntity> implements TPeopleDictionaryService {

    @Autowired
    private  TPeopleDictionaryDao tPeopleDictionaryDao;

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String name = (String)params.get("name");
        IPage<TPeopleDictionaryEntity> page = this.page(
                new Query<TPeopleDictionaryEntity>().getPage(params),
                new QueryWrapper<TPeopleDictionaryEntity>().like(StringUtils.isNotBlank(name),"name", name).orderByDesc("id")
        );
        return new PageUtils(page);
    }

    @Override
    public List<TPeopleDictionaryEntity> listDictionary() {
        List<TPeopleDictionaryEntity> tPeopleDictionaryEntities = tPeopleDictionaryDao.listDictionary();
        return tPeopleDictionaryEntities;
    }

    @Override
    public List<TPeopleDictionaryEntity> listDictionaryPost() {
        List<TPeopleDictionaryEntity> tPeopleDictionaryEntities = tPeopleDictionaryDao.listDictionaryPost();
        return tPeopleDictionaryEntities;
    }

    @Override
    public List<TPeopleDictionaryEntity> listAdministration() {
        List<TPeopleDictionaryEntity> tPeopleDictionaryEntities = tPeopleDictionaryDao.listAdministration();
        return tPeopleDictionaryEntities;
    }

    @Override
    public List<TPeopleDictionaryEntity> listDictionaryTitle() {
        List<TPeopleDictionaryEntity> tPeopleDictionaryEntities = tPeopleDictionaryDao.listDictionaryTitle();
        return tPeopleDictionaryEntities;
    }

    @Override
    public List<TPeopleDictionaryEntity> listPostClass() {
        List<TPeopleDictionaryEntity> tPeopleDictionaryEntities = tPeopleDictionaryDao.listPostClass();
        return tPeopleDictionaryEntities;
    }

    /**
     * 字典类型下拉选择
     */
    public List<TPeopleDictionaryEntity> getPeopleSelect(){return tPeopleDictionaryDao.getPeopleSelect();}
    public List<TTrainingDictionaryEntity> getTrainingSelect(){return tPeopleDictionaryDao.getTrainingSelect();}
    public List<TFightDictionaryEntity> getFightSelect(){return tPeopleDictionaryDao.getFightSelect();}

    /**
     * 人员退出类型
     */
   public List<TPeopleDictionaryEntity> outType(){return tPeopleDictionaryDao.outType();}

}